<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>支付</title>
</head>
<body>
<div id="myQrcode" th:text="${codeUrl}"></div>
<div id="orderId" hidden>${orderId}</div>
<div id="returnUrl" hidden>${returnUrl}</div>

<script src="https://cdn.bootcss.com/jquery/1.5.1/jquery.min.js"></script>
<script src="https://cdn.bootcss.com/jquery.qrcode/1.0/jquery.qrcode.min.js"></script>
<script type="text/javascript" th:inline="javascript">
    jQuery('#myQrcode').qrcode({
        text: [[${codeUrl}]]
    });

    $(function () {
        //定时器
        setInterval(function () {
            console.log('开始查询支付状态...');
            $.ajax({
                'url': '/queryByOrderId',
                data: {
                    'orderId': $('#orderId').text()
                },
                success: function (result) {
                    if (result.status != null
                        && result.status === 1) {
                        location.href = $('#returnUrl').text()
                    }
                },
                error: function (result) {
                    alert(result)
                }
            })
        }, 10000)
    });

</script>
</body>
</html>